      1  /**

      2     This class collects a pair of elements of different types.

      3  */

      4  public class Pair<T, S>

      5  {

      6     private T first;

      7     private S second;

      8

      9     /**

     10        Constructs a pair containing two given elements.

     11        @param firstElement the first element

     12        @param secondElement the second element

     13     */

     14     public Pair(T firstElement, S secondElement)

     15     {

     16        first = firstElement;

     17        second = secondElement;

     18     }

     19

     20     /**

     21        Gets the first element of this pair.

     22        @return the first element

     23     */

     24     public T getFirst() { return first; }

     25

     26     /**

     27        Gets the second element of this pair.

     28        @return the second element

     29     */

     30     public S getSecond() { return second; }

     31

     32     public String toString() { return "(" + first + ", " + second + ")"; }

     33  }